package com.ridaizu.service.impl;

import java.sql.SQLException;
import java.util.List;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

import com.ridaizu.dao.DaoAdapter;
import com.ridaizu.dao.impl.GoodsCatalogTypeDao;
import com.ridaizu.model.GoodsCatalogType;
import com.ridaizu.model.Model;
import com.ridaizu.model.search.SearchModel;
import com.ridaizu.service.Service;

@ManagedBean(name = "goodsCatalogTypeServiceImpl")
@ApplicationScoped
public class GoodsCatalogTypeServiceImpl extends Service {

	private static final long serialVersionUID = 1L;

	private GoodsCatalogTypeDao dao;

	public GoodsCatalogTypeServiceImpl() {
		this.dao = new GoodsCatalogTypeDao();
	}

	@Override
	public void setDao(DaoAdapter dao) {
		this.dao = (GoodsCatalogTypeDao) dao;
	}

	@Override
	public int getCount(SearchModel searchModel) throws SQLException {
		return dao.selectCount(searchModel);
	}

	public List<GoodsCatalogType> getGoodsCatalogTypeList(SearchModel searchModel) throws SQLException {

		return dao.selectGoodsCatalogTypeList(searchModel);
	}

	@Override
	public Model getModel(int... id) throws SQLException {

		return dao.select(id);
	}

	@Override
	public boolean insertModel(Model model) {

		return dao.insert(model) > 0;
	}

	@Override
	public boolean updateModel(Model model) {

		return dao.update(model) > 0;
	}

	public boolean deleteModel(int id) {

		return dao.delete(id) > 0;
	}

}
